package com.xiang.sql.entity;

import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableField;
import java.io.Serializable;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 奖品 数据实体
 * 
 * @author mac-xiang
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName(value = "`prize`", autoResultMap = true)
@ApiModel(value = "奖品 对象", description = "奖品")
public class Prize implements Serializable {

  private static final long serialVersionUID = 1L;
  /** id */
  @TableId(value = "id", type = IdType.ASSIGN_ID)
  public String id;

  /** 名称 */
  @TableField(value = "`name`", fill = FieldFill.INSERT)
  public String name;

  /** 名称颜色 */
  @TableField(value = "`name_color`", fill = FieldFill.INSERT)
  public String nameColor;

  /** 背景颜色 */
  @TableField(value = "`bg_color`", fill = FieldFill.INSERT)
  public String bgColor;

  /** 图片地址 */
  @TableField(value = "`image`", fill = FieldFill.INSERT)
  public String image;

  /** 数量 */
  @TableField(value = "`sum`", fill = FieldFill.INSERT)
  public Integer sum;

  /** 概率 */
  @TableField(value = "`weight`", fill = FieldFill.INSERT)
  public Integer weight;

  /** 内容 */
  @TableField(value = "`value`", fill = FieldFill.INSERT)
  public String value;

  public Prize() {
  }

  public Long money() {
    if (this.value != null && this.value.length() > 7 && this.value.indexOf("money:") == 0) {
      try {
        return Long.valueOf(this.value.substring(6));
      } catch (Exception e) {
      }
    }
    return null;
  }
}